import threading
import time


class GetListHtml(threading.Thread):

    def __init__(self, url_list: list):
        super().__init__()
        self.url_list = url_list

    def run(self):
        for i in range(30):
            time.sleep(1)
            print('获取到详情页')
            self.url_list.append(f'www.baidu.com/{i}')


class GetDetailHtml(threading.Thread):

    def __init__(self, url_list: list):
        super().__init__()
        self.url_list = url_list

    def run(self):
        while True:
            time.sleep(1)
            if self.url_list:
                url = self.url_list.pop()
                print(f'请求详情页{url}')


if __name__ == '__main__':
    url_list = []
    t1 = GetListHtml(url_list)
    t2 = GetDetailHtml(url_list)

    t1.start()
    t2.start()
